<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" href="${pageContext.request.contextPath }/bootstrap/img/favicon.ico">
<link href="${pageContext.request.contextPath }/bootstrap/css/style.min.css?v=4.0.0" rel="stylesheet">
<link href="${pageContext.request.contextPath }/bootstrap/css/animate.min.css" rel="stylesheet">
<link href="${pageContext.request.contextPath }/bootstrap/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
<link href="${pageContext.request.contextPath}/bootstrap/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
<link href="${pageContext.request.contextPath }/bootstrap/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/bootstrap/css/jquery-confirm.css"/>
<%-- <link href="${pageContext.request.contextPath }/bootstrap/css/plugins/datapicker/datepicker3.css" rel="stylesheet"> --%>
<link href="${pageContext.request.contextPath }/bootstrap/css/bootstrap-datetimepicker.min.css" rel="stylesheet" />
<link href="${pageContext.request.contextPath }/bootstrap/js/plugins/fancybox/jquery.fancybox.css" rel="stylesheet"/>
<title>医生端管理</title>
</head>
<body>
		<!-- <div id="toolbar" class="btn-group">  
            <button id="btn_edit" type="button" class="btn btn-default">  
                <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>刷新  
            </button>
        </div> -->
        
    <div class="panel panel-default">
	    <div class="panel-body form-group" style="margin-top: 0px;">
	        <label class="col-sm-1 control-label" style="text-align: right; margin-top:5px">医生职称：</label>
	        <div class="col-sm-2">
	            <select class="form-control" name="doctitle" id="doctitle1">
					<option value="">---请选择---</option>
				</select>
	        </div>
	        <label class="col-sm-1 control-label" style="text-align: right; margin-top:5px">年龄大于：</label>
	        <!-- <div class="col-sm-2">
	            <input type="text" class="form-control" name="docage" id="docage"/>
	        </div> -->
	        <div class="col-sm-1 form-group">
            	<div class="input-daterange input-group" id="docage1">
                	<input type="text" class="input-md form-control" name="docage" id="docage" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" />
            		<span class="input-group-addon">岁</span>
            	</div>
            </div>
            <label class="col-sm-1 control-label" style="text-align: right; margin-top:5px">注册手机：</label>
	        <div class="col-sm-2">
	            <input type="text" class="form-control" name="docloginphone" id="docloginphone1"/>
	        </div>
	        <label class="col-sm-1 control-label" style="text-align: right; margin-top:5px">所属医院级别：</label>
	        <div class="col-sm-2">
	            <select class="form-control" name="dochosplevel" id="dochosplevel1">
					<option value="">---请选择---</option>
				</select>
	        </div>
	    </div>
	    <div class="panel-body form-group" style="margin-top: 0px;">
	        <label class="col-sm-1 control-label" style="text-align: right; margin-top:5px">所属科室：</label>
	        <div class="col-sm-2">
	            <select class="form-control" name="dochospfdept" id="dochospfdept1" onchange="loadhospsdept();">
					<option value="0">---请选择一级科室---</option>
				</select>
	        </div>
	        <div class="col-sm-2">
	            <select class="form-control" name="dochospsdept" id="dochospsdept1">
					<option value="0">---请选择二级科室---</option>
				</select>
	        </div>
	        <label class="col-sm-1 control-label" style="text-align: right; margin-top:5px">审核情况：</label>
	        <div class="col-sm-1">
	            <select class="form-control" name="type" id="type">
					<option value="0">全部</option>
					<option value="1">未审核</option>
					<option value="2">等待审核</option>
					<option value="3">已审核</option>
					<option value="4">未通过审核</option>
				</select>
	        </div>
	        <label class="col-sm-1 control-label" style="text-align: right; margin-top:5px">审核提交时间：</label>
	        <div class="col-sm-3 form-group">
                <div class="input-daterange input-group" id="datepicker">
                    <input type="text" class="input-md form-control" id="startdatetime" name="startdatetime" value="" />
                    <span class="input-group-addon">到</span>
                    <input type="text" class="input-md form-control" id="enddatetime" name="enddatetime" value="" />
                </div>
            </div>
	        <div class="col-sm-1 control-label">
	            <button class="btn btn-primary" id="search_btn">查询</button>
	        </div>
	     </div>
	</div>
	
    <!-- 动态加载table -->
	<table id="doctortab" class="table table-hover"></table>
	
	<div class="modal inmodal fade" id="DoctorDetailsModal" tabindex="-1" role="dialog"  aria-hidden="true">
    	<div class="modal-dialog" style="width: 1200px">
        	<div class="modal-content">
            	<div class="modal-header">
                	<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h3 class="modal-title">用户详情</h3>
               	</div>
                <div class="modal-body">
                    <div class="wrapper wrapper-content">
        				<div class="row animated fadeInRight">
                    		<div class="col-sm-3">
                				<div class="ibox float-e-margins">
                    				<div class="ibox-title">
				                        <h4>个人登陆资料</h4>
				                    </div>
				                    <div>
				                    	<div class="ibox-content profile-content">
			                    			<img alt="image" id="docloginpix" style="max-width:100px" class="img-rounded" src="${pageContext.request.contextPath}/bootstrap/img/a5.jpg">
			                    		</div>
			                    		<div class="ibox-content profile-content">
			                    			<p><i class="fa fa-user"> 登陆手机号码：</i><strong><a id="docloginphone"></a></strong></p>
				                            <hr/>
				                            <p><i class="fa fa-user"> 登陆账号审核状态：</i><strong><a id="doclogintypename"></a></strong></p>
				                            <hr/>
				                            <p><i class="fa fa-map-marker"> 上次登陆时间：</i><strong><a id="doclogintime"></a></strong></p>
				                            <hr/>
			                    		</div>
				                    </div>
				                </div>
				        	</div>
				        	<div class="col-sm-9">
                				<div class="ibox float-e-margins">
                    				<div class="ibox-title">
				                        <h4>个人详细信息</h4>
				                    </div>
				                    <div class="ibox-content">
			                    		<div class="row">
			                    			<div class="col-sm-6">
			                    				<p><i class="fa fa-user"> 真实姓名：</i><strong><a id="docname"></a></strong></p>
												<hr/>
						                    	<p><i class="fa fa-user"> 年龄：</i><strong><a id="docage"></a></strong></p>
						                    	<hr/>
						                    	<p><i class="fa fa-credit-card"> 身份证号码：</i><strong><a id="doccardnum"></a></strong></p>
						                 		<hr/>
						                 		<p><i class="fa fa-credit-card"> 所在第一科室：</i><strong><a id="docprimarydept"></a></strong></p>
						                 		<hr/>
						                 		<p><i class="fa fa-credit-card"> 所在经度：</i><strong><a id="dochosplon"></a></strong></p>
						                 		<hr/>
						                 		<p><i class="fa fa-credit-card"> 所在地址：</i><strong><a id="address1"></a></strong></p>
						                 		<hr/>
						                 		<p><i class="fa fa-credit-card"> 所在医院：</i><strong><a id="dochosp"></a></strong></p>
						                 		<hr/>
			                    			</div>
			                    			<div class="col-sm-6">
			                    				<p><i class="fa fa-user"> 性别：</i><strong><a id="docmale"></a></strong></p>
												<hr/>
						                    	<p><i class="fa fa-user"> 职称：</i><strong><a id="doctitle"></a></strong></p>
						                    	<hr/>
						                 		<p><i class="fa fa-credit-card"> 是否全天接诊：</i><strong><a id="docallday"></a></strong></p>
						                 		<hr/>
						                    	<p><i class="fa fa-credit-card"> 所在第二科室：</i><strong><a id="docseconddept"></a></strong></p>
						                 		<hr/>
						                 		<p><i class="fa fa-credit-card"> 所在纬度：</i><strong><a id="dochosplat"></a></strong></p>
						                 		<hr/>
						                 		<p><i class="fa fa-credit-card"> 所在区和路：</i><strong><a id="address2"></a></strong></p>
						                 		<hr/>
						                 		<p><i class="fa fa-credit-card"> 所在医院等级：</i><strong><a id="hosplevel"></a></strong></p>
						                 		<hr/>
			                    			</div>
			                    			<!-- 显示照片 -->
			                    			<div id="photoPanel">
			                    				
			                    			</div>
			                    		</div>
				                    </div>
				                </div>
				        	</div>
        				</div>
        			</div>
                </div>
				<div class="modal-footer">
                	<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
           		</div>
           	</div>
        </div>
	</div>
	<div class="modal inmodal fade" id="EditModal" tabindex="-1" role="dialog"  aria-hidden="true">
    	<div class="modal-dialog modal-lg" style="width:800px;">
        	<div class="modal-content">
            	<div class="modal-header">
                	<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title">编辑医生信息</h4>
               	</div>
                <div class="modal-body">
                	<div class="row">
                		<div class="col-sm-6">
                			<div class="form-group draggable">
		                    	<label class="control-label">真实姓名：</label>
		                        <input type="text" name="docname" id="Edocname" class="form-control" placeholder="医生真实姓名">
		                   	</div>
                		</div>
                		<div class="col-sm-3">
                			<div class="form-group draggable">
		                    	<label class="control-label">性别：</label>
		                        <select class="form-control" name="docmale" id="Edocmale">
		                        	<option value="男">男</option>
		                        	<option value="女">女</option>
								</select>
		                   	</div>
                		</div>
                		<div class="col-sm-3">
                			<div class="form-group draggable">
		                    	<label class="control-label">年龄：</label>
		                        <input type="text" name="docage" id="Edocage" class="form-control" placeholder="医生年龄">
		                   	</div>
                		</div>
                		<div class="col-sm-6">
                			<div class="form-group draggable">
		                    	<label class="control-label">职称：</label>
		                        <select class="form-control" name="doctitle" id="Edoctitle">
									<option value="0">---请选择---</option>
								</select>
		                   	</div>
                		</div>
                		<div class="col-sm-6">
                			<div class="form-group draggable">
		                    	<label class="control-label">身份证号码：</label>
		                        <input type="text" name="doccardnum" id="Edoccardnum" class="form-control" placeholder="身份证号码">
		                   	</div>
                		</div>
                		<div class="col-sm-6">
                			<div class="form-group draggable">
		                    	<label class="control-label">所在医院名称：</label>
		                        <input type="text" name="dochosp" id="Edochosp" class="form-control" placeholder="">
		                   	</div>
                		</div>
                		<div class="col-sm-6">
                			<div class="form-group draggable">
		                    	<label class="control-label">所在医院地址：</label>
		                        <input type="text" name="dochospadr" id="Edochospadr" class="form-control" placeholder="">
		                        <input type="hidden" id="Edochospprovince"/><input type="hidden" id="Edochospcity"/>
		                        <input type="hidden" id="Edochosparea"/><input type="hidden" id="Edochospother"/>
		                        <input type="hidden" id="Edochosplon" value="117.171056"/><input type="hidden" id="Edochosplat" value="31.833742"/>
		                   	</div>
                		</div>
                		<div class="col-sm-6">
                			<div class="form-group draggable">
		                    	<label class="control-label">所在医院等级：</label>
		                        <select class="form-control" name="hosplevel" id="Ehosplevel">
									<option value="0">---请选择---</option>
								</select>
		                   	</div>
                		</div>
                		<div class="col-sm-3">
                			<div class="form-group draggable">
		                    	<label class="control-label">所在医院一级科室：</label>
		                        <select class="form-control" name="docprimarydept" id="Edocprimarydept" onchange="">
									<option value="0">---请选择---</option>
								</select>
		                   	</div>
                		</div>
                		<div class="col-sm-3">
                			<div class="form-group draggable">
		                    	<label class="control-label">所在医院二级科室：</label>
								<select class="form-control" name="docseconddept" id="Edocseconddept">
									<option value="0">---请选择---</option>
								</select>
		                   	</div>
                		</div>
                		<!-- <div class="col-sm-6">
                			<div class="form-group draggable">
		                    	<label class="control-label">医生简介：</label>
		                        <textarea name="docabs" id="Edocabs" rows="4" class="form-control" placeholder="医生简介"></textarea>
		                   	</div>
                		</div>
                		<div class="col-sm-6">
                			<div class="form-group draggable">
		                    	<label class="control-label">擅长疾病：</label>
		                        <textarea name="docexpert" id="Edocexpert" rows="4" class="form-control" placeholder="医生简介"></textarea>
		                   	</div>
                		</div> -->
                	</div>
                </div>
				<div class="modal-footer">
                	<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                	<button type="button" class="btn btn-primary" onclick="docinfoSubmit();" id="docinfoBtn">提交</button>
           		</div>
           	</div>
        </div>
	</div>
	<div class="modal fade" id="myMapModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" >
		<div class="modal-dialog" style="width: 1000px;height:800px;">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true"> &times;</button>
					<h4 class="modal-title" id="myModalLabel"><a>百度地图选点(鼠标滑动放大缩小地图,左击拖动移动地图。点击获取经纬度)</a></h4>
				</div>
				<div class="modal-body" id="map_main" style="height:500px;">地图容器</div>
				<div class="modal-footer">
					<input style="width:300px;float:left;" type="text" placeholder="左击地点，生成经纬度" value="" id="map_txt" class="form-control" readonly=""/>
					<!-- 经度 -->
					<input type="hidden" id="lng"/>
					<!-- 纬度 -->
					<input type="hidden" id="lat"/>
					<!-- 省 -->
					<input type="hidden" id="province"/>
					<!-- 市 -->
					<input type="hidden" id="city"/>
					<!-- 区 -->
					<input type="hidden" id="area"/>
					<!-- 街 -->
					<input type="hidden" id="other"/>
					<button type="button" class="btn btn-primary" onclick="setMapValue()" data-dismiss="modal">设置为此地址</button>
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				</div>
			</div>
		</div>
	</div>
    <script src="${pageContext.request.contextPath }/bootstrap/js/jquery.min.js?v=2.1.4"></script>
    <script src="${pageContext.request.contextPath }/bootstrap/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath }/bootstrap/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="${pageContext.request.contextPath }/bootstrap/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="${pageContext.request.contextPath }/bootstrap/js/jquery-confirm.js"></script>
    <%-- <script src="${pageContext.request.contextPath }/bootstrap/js/plugins/datapicker/bootstrap-datepicker.js"></script>
    <script src="${pageContext.request.contextPath }/bootstrap/js/plugins/cropper/cropper.min.js"></script>
    <script src="${pageContext.request.contextPath }/bootstrap/js/demo/form-advanced-demo.min.js"></script> --%>
    <script src="${pageContext.request.contextPath }/bootstrap/js/moment-with-locales.min.js"></script>
	<script src="${pageContext.request.contextPath }/bootstrap/js/bootstrap-datetimepicker.min.js"></script>
	<script src="${pageContext.request.contextPath }/bootstrap/js/plugins/fancybox/jquery.fancybox.js"></script>
	<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=2d12993ce41407db4050140fe342d9ba"></script>
    <script type="text/javascript">
	  	//根据窗口调整表格高度
	    $(window).resize(function() {
	        $('#doctortab').bootstrapTable('resetView', {
	            height: tableHeight()
	        })
	    })
	    //查询按钮事件
	    $('#search_btn').click(function(){
	        //$('#doctortab').bootstrapTable('refresh');
	        $('#doctortab').bootstrapTable('refresh',{url: '${pageContext.request.contextPath}/Main/Doctor/doctorListAjax.action'});
	    })
	    //tableHeight函数
	    function tableHeight(){
	        //可以根据自己页面情况进行调整
	        return $(window).height()-220;
	    }
	  	function refreshTab(){
	  		$('#doctortab').bootstrapTable('refresh');
	  	}
		//生成用户数据
	    $('#doctortab').bootstrapTable({
	        method: 'get',
	        contentType: "application/x-www-form-urlencoded",//必须要有！！！！
	        url:"${pageContext.request.contextPath}/Main/Doctor/doctorListAjax.action",//要请求数据的文件路径
	        height:tableHeight(),//高度调整
	        striped: true, //是否显示行间隔色
	        dataField: "rows",//bootstrap table 可以前端分页也可以后端分页，这里
	        //我们使用的是后端分页，后端分页时需返回含有total：总记录数,这个键值好像是固定的  
	        //rows： 记录集合 键值可以修改  dataField 自己定义成自己想要的就好
	        pageNumber: 1, //初始化加载第一页，默认第一页
	        pagination:true,//是否分页
	        queryParamsType:'limit',//查询参数组织方式
	        queryParams:function(params) {//自定义参数，这里的参数是传给后台的，我这是是分页用的    
	            return {//这里的params是table提供的    
	                offset : params.offset,//从数据库第几条记录开始    
	                limit : params.limit,
	                type:$('#type').val(),
	                doctitle:$('#doctitle1').val(),
	                docage:$('#docage1').val(),
	                docloginphone:$('#docloginphone1').val(),
	                dochosplevel:$('#dochosplevel1').val(),
	                dochospfdept:$('#dochospfdept1').val(),
	                dochospsdept:$('#dochospsdept1').val(),
	                startdatetime:$('#startdatetime').val(),
	                enddatetime:$('#enddatetime').val()
	            //找多少条    
	            };},//请求服务器时所传的参数
	        sidePagination:'server',//指定服务器端分页
	        pageSize:10,//单页记录数
	        pageList:[1,5,10,30,50,100],//分页步进值
	        showRefresh:true,//刷新按钮
	        showColumns:true,
	        clickToSelect: true,//是否启用点击选中行
	        toolbarAlign:'right',//工具栏对齐方式
	        buttonsAlign:'right',//按钮对齐方式
	        toolbar:'#toolbar',//指定工作栏
	        columns:[
	            {
	                title:'全选',
	                field:'select',
	                //复选框
	                checkbox:true,
	                width:25,
	                align:'center',
	                valign:'middle'
	            },
	            {
	                title:'医生端登陆ID',
	                field:'docloginid'
	            },
	            {
	                title:'医生姓名',
	                field:'docname'
	            },
	            {
	                title:'医生性别',
	                field:'docmale'
	            },
	            {
	                title:'医生登陆手机号',
	                field:'docloginphone'
	            },
	            {
	                title:'医生职称',
	                field:'doctitle'
	            },
	            {
	                title:'医生账户状态',
	                field:'doclogintypename'
	            },
	            {
	                title:'操作',
	                field:'doclogintype',
	              	//列数据格式化
	                formatter:operate
	            },
	        ],
	        locale:'zh-CN',//中文支持,
	        responseHandler:function(rows){
	            //在ajax获取到数据，渲染表格之前，修改数据源
	            return rows;
	        }
	    })
	    //操作序列规则化
		function operate(value,row,index){
	    	return '<button class="btn btn-primary" style="height:30px" onclick="Details('+row.docloginid+')">详情</button>&nbsp;&nbsp;<button class="btn btn-info" style="height:30px" onclick="EditInfo('+row.docloginid+')">编辑</button>';
		}
	    function Details(docloginid){
    		//alert(docloginid);
    		$.ajax({
    			type:"post",
    			url:"${pageContext.request.contextPath}/Main/Doctor/getDoctorDetails.action",
    			data:"docloginid="+docloginid,
    			async: true,
        		success:function(data){
        			//alert("data.details.docname="+data.details.docname);
        			if(data.code==100){
        				$('#DoctorDetailsModal').modal('show');
        				ModalPadding(data.details);
        			}else{
        				$.alert(data.msg);
        			}
        		},error:function(request){
        			
        		}
    		})
    	}
	    function EditInfo(docloginid){
	    	$.ajax({
    			type:"post",
    			url:"${pageContext.request.contextPath}/Main/Doctor/getDoctorDetails.action",
    			data:"docloginid="+docloginid,
    			async: true,
        		success:function(data){
        			//alert("data.details.docname="+data.details.docname);
        			if(data.code==100){
        				var details=data.details;
        				$("#EditModal").modal("show");
        				$("#Edocname").val(details.docname);
        		    	$("#Edocmale").val(details.docmale);
        		    	$("#Edocage").val(details.docage);
        		    	$("#Edochospadr").val(details.dochospprovince+":"+details.dochospcity+":"+details.dochosparea+":"+details.dochospother+":"+details.dochosplon+":"+details.dochosplat);
        		    	$("#Edochospprovince").val(details.dochospprovince);
        		    	$("#Edochospcity").val(details.dochospcity);
        		    	$("#Edochosparea").val(details.dochosparea);
        		    	$("#Edochospother").val(details.dochospother);
        		    	$("#Edochosplon").val(details.dochosplon);
        		    	$("#Edochosplat").val(details.dochosplat);
        		    	$("#Edoctitle").val(details.doctitle);
        		    	$("#Edoccardnum").val(details.doccardnum);
        		    	$("#Edochosp").val(details.dochosp);
        		    	$("#Ehosplevel").val(details.hosplevel);
        		    	$("#Edocprimarydept").val(details.docprimarydept);
        		    	//$("#Edocexpert").val(details.docexpert);
        		    	//$("#Edocabs").val(details.docabs);
        		    	$.ajax({
        	    			type:"post",
        	    			url:"${pageContext.request.contextPath}/Main/Doctor/Eloadhospdept.action",
        	    			data:"hospdeptfatheridname="+details.docprimarydept,
        	    			async: true,
        	        		success:function(data){
        	        			if(data.code==100){
        	        				var datalist = data.list;
        	                        $('#Edocseconddept').append("<option value='0' selected='selected' >" + '---请选择---' + "</option>");  
        	                        for (var i = 0; i < datalist.length; i++) {  
        	                            $('#Edocseconddept').append("<option value='" + datalist[i].hospdeptname + "' >" + datalist[i].hospdeptname + "</option>");  
        	                        }
        	        				$("select#Edocseconddept").val(details.docseconddept);
        	        			}
        	        		},error:function(request){
        	        			$.alert("二级部门加载失败");
        	        		}
        		    	});
        			}else{
        				$.alert(data.msg);
        			}
        		},error:function(request){
        			$.alert("医生信息加载失败");
        		}
    		})
	    }
	    function datastandard(data){
	    	if(data=='true'){
	    		return "是";
	    	}else if(data=='false'){
	    		return "否";
	    	}else{
	    		return "";
	    	}
	    }
	    function ModalPadding(data){
	    	$("#photoPanel").html("");
	    	$("#docloginpix").attr('src',data.docloginpix);//登陆头像
			$("#docloginphone").html(data.docloginphone);//登录手机号码
			$("#doclogintypename").html(data.doclogintypename);//账号登陆状态字
			$("#doclogintime").html(data.doclogintime);//上次登陆时间
			
			$("#docname").html(data.docname);//真实姓名
			$("#docmale").html(data.docmale);//性别
			$("#docage").html(data.docage);//年龄
			$("#doctitle").html(data.doctitle);//职称
			$("#doccardnum").html(data.doccardnum);//身份证号码
			$("#docallday").html(datastandard(data.docallday));//是否全天接诊
			$("#docprimarydept").html(data.docprimarydept);//所在第一科室
			$("#docseconddept").html(data.docseconddept);//所在第二科室
			$("#dochosplon").html(data.dochosplon);//所在经度
			$("#dochosplat").html(data.dochosplat);//所在纬度
			$("#address1").html(data.dochospprovince+","+data.dochospcity);//所在地址
			$("#address2").html(data.dochosparea+","+data.dochospother);//所在地址
			$("#dochosp").html(data.dochosp);//所在医院
			$("#hosplevel").html(data.hosplevel);//所在医院等级
			for(var i=0;i<data.doctitlephoto.length;i++){
				var doctitlephoto=data.doctitlephoto[i];
				var photoname="职称执业医师资格证照片*"+Number(i+1);
				if(doctitlephoto!=""){
					AddPhotoPanel(doctitlephoto,photoname);
				}
			}
			for(var i=0;i<data.docworkcardphoto.length;i++){
				var docworkcardphoto=data.docworkcardphoto[i];
				var photoname="医生工牌照片*"+Number(i+1);
				if(docworkcardphoto!=""){
					AddPhotoPanel(docworkcardphoto,photoname);
				}
			}
			for(var i=0;i<data.doccardphoto.length;i++){
				var doccardphoto=data.doccardphoto[i];
				var photoname="身份证照片*"+Number(i+1);
				if(doccardphoto!=""){
					AddPhotoPanel(doccardphoto,photoname);
				}
			}
			for(var i=0;i<data.docqualphoto.length;i++){
				var docqualphoto=data.docqualphoto[i];
				var photoname="行医资格证照片*"+Number(i+1);
				if(docqualphoto!=""){
					AddPhotoPanel(docqualphoto,photoname);
				}
			}
			for(var i=0;i<data.docotherphoto.length;i++){
				var docotherphoto=data.docotherphoto[i];
				var photoname="其他照片*"+Number(i+1);
				if(docotherphoto!=""){
					AddPhotoPanel(docotherphoto,photoname);
				}
			}
	    }
	    
	    function AddPhotoPanel(data,photoname){
	    	$("#photoPanel").append('<div class="col-sm-6">'+
			    	'<div class="panel panel-default">'+
			    	'<div class="panel-heading">'+
		            	'<h5 class="panel-title">'+
		                	'<a data-toggle="collapse" data-parent="#accordion" href="javscript:;">'+photoname+'</a>'+
		            	'</h5>'+
		            '</div>'+
		     		'<div id="" class="panel-collapse collapse in">'+
	                	'<div class="panel-body">'+
	                       	'<a class="fancybox" target="_blank" href="'+data+'" title="'+photoname+'">'+
					        	'<img alt="image" src="'+data+'" style="width:320px;height:180px;"/>'+
						    '</a> '+
	            		'</div>'+
	            	'</div>'+
	           ' </div>'+
	    	'</div>');
	    }
	    
	    function docinfoSubmit(){
	    	var docname=$("#Edocname").val();
	    	var docmale=$("#Edocmale").val();
	    	var docage=$("#Edocage").val();
	    	var doctitle=$("#Edoctitle").val();
	    	var doccardnum=$("#Edoccardnum").val();
	    	var dochosp=$("#Edochosp").val();
	    	var dochospprovince = $("#Edochospprovince").val();
	    	var dochospcity = $("#Edochospcity").val();
	    	var dochosparea = $("#Edochosparea").val();
	    	var dochospother = $("#Edochospother").val();
	    	var dochosplon = $("#Edochosplon").val();
	    	var dochosplat = $("#Edochosplat").val();
	    	var hosplevel=$("#Ehosplevel").val();
	    	var docprimarydept=$("#Edocprimarydept").val();
	    	var docseconddept=$("#Edocseconddept").val();
	    	//var docexpert=$("#Edocexpert").val();
	    	//var docabs=$("#Edocabs").val();
	    	var param="docname="+docname+"&docmale="+docmale+"&docage="+docage+"&doctitle="+doctitle+"&doccardnum="+doccardnum+
	    	"&dochosp="+dochosp+"&hosplevel="+hosplevel+"&docprimarydept="+docprimarydept+"&docseconddept="+docseconddept+
	    	"&dochospprovince"+dochospprovince+"&dochospcity="+dochospcity+"&dochosparea="+dochosparea+"&dochospother="+dochospother+
	    	"&dochosplon="+dochosplon+"&dochosplat="+dochosplat;
	    	//"&docexpert="+docexpert+"&docabs="+docabs;
	    	$.confirm({
	    		title: '提示!',
    		    content: '您确定要提交保存？',
    		    type: 'blue',
    		    typeAnimated: true,
    		    buttons: {
    		    	确定: function () {
    		    		$("#docinfoBtn").html('<i class="fa fa-spinner fa-spin"></i>处理中...');
    		    		$("#docinfoBtn").prop('disabled',true);
    		    		$.ajax({
    		    			type:"post",
    		    			url:"${pageContext.request.contextPath}/Main/Doctor/doctorinfoSubmit.action",
    		    			data:param,
    		    			async: true,
    		    			success:function(data){
    		    				$("#docinfoBtn").html('提交');
    	    		    		$("#docinfoBtn").prop('disabled',false);
    		        			$.alert(data.msg);
    		    				if(data.code==100){
    		    					$('#EditModal').modal('hide');
    		        				refreshTab();
    		    				}
    		    			},error:function(request){
    		    				$("#docinfoBtn").html('提交');
    	    		    		$("#docinfoBtn").prop('disabled',false);
    		        			$.alert("向服务器请求失败！");
    		    			}
    		    		});
    		    	},
    		    	取消:function(){},
    		    }
	    	})
	    }
	</script>
	<script type="text/javascript">
		$(function () {
			$('#startdatetime').datetimepicker({  
				format: 'YYYY-MM-DD',  
				locale: moment.locale('zh-cn')  
			});
			$('#enddatetime').datetimepicker({  
				format: 'YYYY-MM-DD',  
				locale: moment.locale('zh-cn')  
			});
			$.ajax({
    			type:"post",
    			url:"${pageContext.request.contextPath}/Main/Doctor/loaddoctitile.action",
    			async: true,
        		success:function(data){
        			//alert("data.details.docname="+data.details.docname);
        			if(data.code==100){
        				var datalist = data.list;
                        for (var i = 0; i < datalist.length; i++) {  
                            $('#doctitle1').append("<option value='" + datalist[i].doctitlename + "' >" + datalist[i].doctitlename + "</option>");  
                            $('#Edoctitle').append("<option value='" + datalist[i].doctitlename + "' >" + datalist[i].doctitlename + "</option>");  
                        }
        			}else{
        				$.alert(data.msg);
        			}
        		},error:function(){
        			$.alert("加载医生职称失败!!!");
        		}
    		})
    		
    		$.ajax({
    			type:"post",
    			url:"${pageContext.request.contextPath}/Main/Doctor/loadhosplevel.action",
    			async: true,
        		success:function(data){
        			//alert("data.details.docname="+data.details.docname);
        			if(data.code==100){
        				var datalist = data.list;
                        for (var i = 0; i < datalist.length; i++) {  
                            $('#dochosplevel1').append("<option value='" + datalist[i].hosplevelname + "' >" + datalist[i].hosplevelname + "</option>");  
                            $('#Ehosplevel').append("<option value='" + datalist[i].hosplevelname + "' >" + datalist[i].hosplevelname + "</option>");  
                        }
        			}else{
        				$.alert(data.msg);
        			}
        		},error:function(){
        			$.alert("加载所属医院级别失败!!!");
        		}
    		})
    		
    		$.ajax({
    			type:"post",
    			url:"${pageContext.request.contextPath}/Main/Doctor/loadhospdept.action",
    			async: true,
    			data:"hospdeptfatherid=0",
        		success:function(data){
        			//alert("data.details.docname="+data.details.docname);
        			if(data.code==100){
        				var datalist = data.list;
                        for (var i = 0; i < datalist.length; i++) {  
                            $('#dochospfdept1').append("<option value='" + datalist[i].hospdeptid + "' >" + datalist[i].hospdeptname + "</option>");  
                        	$('#Edocprimarydept').append("<option value='" + datalist[i].hospdeptname + "' >" + datalist[i].hospdeptname + "</option>");
                        }
        			}else{
        				$.alert(data.msg);
        			}
        		},error:function(){
        			$.alert("加载一级科室失败!!!");
        		}
    		})
	    });
		function loadhospsdept(){
	    	var dochospfdept = $("#dochospfdept1").val();
    		if(dochospfdept==0){
                $("#dochospsdept1").empty();
                $('#dochospsdept1').append("<option value='0' selected='selected' >" + '---请选择二级科室---' + "</option>");  
    		}else{
    			$("#dochospsdept1").empty();
    			$.ajax({  //页面首加载一级部门下拉框数据
                    type: "post",  
                    url: "${pageContext.request.contextPath}/Main/Doctor/loadhospdept.action",
            		async: true,
                    data:"hospdeptfatherid="+dochospfdept,
                    success: function (data) {
                    	var datalist = data.list;
                        $('#dochospsdept1').append("<option value='0' selected='selected' >" + '---请选择二级科室---' + "</option>");  
                        for (var i = 0; i < datalist.length; i++) {  
                            $('#dochospsdept1').append("<option value='" + datalist[i].hospdeptid + "' >" + datalist[i].hospdeptname + "</option>");  
                        }  
                    },  
                    error: function () {  
                        $.alert("加载一级部门失败!!!");  
                    }  
                });
    		}
	    }
		 /* function EditInfo(){
			$("#EditModal").modal("show");
			$('#Edocmale').append("<option value='男'>" + '男' + "</option>");
			$('#Edocmale').append("<option value='女'>" + '女' + "</option>");
			var value="女";
			$("select#Edocmale").val(value);
			
			
		} */
	</script>
	<script type="text/javascript">
	$(document).ready(function(){
    	$("#Edochospadr").click(function(){
    		$("#myMapModal").modal('show');
             setTimeout(function() {     //添加延时加载。解决问题
                 var map = new BMap.Map("map_main");
                 var myCity = new BMap.LocalCity();
                 var gc = new BMap.Geocoder();  //初始化，Geocoder类
                 myCity.get(function(res){
                     map.centerAndZoom(res.center,res.level);
                     map.enableScrollWheelZoom(); 		// 开启鼠标滚轮缩放，重要！
                     //向地图中添加缩放控件
                 	var ctrl_nav = new BMap.NavigationControl({anchor:BMAP_ANCHOR_TOP_LEFT,type:BMAP_NAVIGATION_CONTROL_LARGE});
                 	map.addControl(ctrl_nav);
                         //向地图中添加缩略图控件
                 	var ctrl_ove = new BMap.OverviewMapControl({anchor:BMAP_ANCHOR_BOTTOM_RIGHT,isOpen:1});
                 	map.addControl(ctrl_ove);
                         //向地图中添加比例尺控件
                 	var ctrl_sca = new BMap.ScaleControl({anchor:BMAP_ANCHOR_BOTTOM_LEFT});
                 	map.addControl(ctrl_sca);
                     /* var old_map = $('#map').val();      //如果已设置过
                     if(old_map.length > '5'){            //打开的时候显示已设置的
                         $("#map_txt").val(old_map);     
                         var oldMap = old_map.split(",");
                         var point = new BMap.Point(oldMap[0],oldMap[1]);    
                         var marker = new BMap.Marker(point);        // 创建标注    
                         map.clearOverlays();
                         map.addOverlay(marker);
                     } */
                     var dochosplon = $("#Edochosplon").val();
                     var dochosplat = $("#Edochosplat").val();
                     if(dochosplon!="" && dochosplat!=""){
                    	 var point = new BMap.Point(dochosplon,dochosplat);    
                         var marker = new BMap.Marker(point);        // 创建标注    
                         map.clearOverlays();
                         map.addOverlay(marker);
                     }
                     map.addEventListener("click", function(e){
                         var lng_lat = e.point.lng+','+e.point.lat;
                         var point = new BMap.Point(e.point.lng,e.point.lat);    
                         var marker = new BMap.Marker(point);        // 创建标注  
                         gc.getLocation(point,function(rs){
                        	 var addComp = rs.addressComponents;
                        	 var province = addComp.province;//省  
                             var city = addComp.city;  //市
                             var area = addComp.district;//区
                             var street = addComp.street;//街
                             var streetnumber = addComp.streetNumber;
                             var Str = province+":"+city+":"+area+":"+street+":"+streetnumber;
                             $("#map_txt").val(lng_lat+"/"+Str);  //加入到设置框
                             $("#lng").val(e.point.lng);$("#lat").val(e.point.lat);
                             $("#province").val(province);$("#city").val(city);
                             $("#area").val(area);$("#other").val(street+streetnumber);
                         })
                         map.clearOverlays();
                         map.addOverlay(marker);
                     });
                 });
             },300);
         });
    });	
	function setMapValue(){
		var lng = $("#lng").val();
		var lat = $("#lat").val();
		var province = $("#province").val();
		var city = $("#city").val();
		var area = $("#area").val();
		var other = $("#other").val();
		$("#Edochospprovince").val(province);
    	$("#Edochospcity").val(city);
    	$("#Edochosparea").val(area);
    	$("#Edochospother").val(other);
    	$("#Edochosplon").val(lng);
    	$("#Edochosplat").val(lat);
    	$("#Edochospadr").val(province+":"+city+":"+area+":"+other+":"+lng+":"+lat);
	}
	</script>
</body>
</html>